package com.laicunba.ext.web.controller.console.sys;

import org.json.simple.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.laicunba.ext.web.controller.BaseController;
import com.laicunba.util.CacheUtil;
import com.laicunba.util.StringUtil;

@SuppressWarnings("unchecked")
@Controller
@RequestMapping(value = "/console/ext/sys")
public class ClearPayoutLockController extends BaseController {

	@RequestMapping(value = "/clear_payout_lock.htm")
	public ModelAndView clearPayoutLock(String type) {
		ModelAndView view = new ModelAndView();
		view.setViewName("clear_payout_lock.jsp");
		return view;
	}

	@ResponseBody
	@RequestMapping(value = "/do_clear_payout_lock.htm")
	public String doClearPayoutLock(String hid, String did) {
		JSONObject json = new JSONObject();
		String key = null;
		if (StringUtil.isNotEmpty(hid)) {
			key = "sys.submit.fuiou.pay.h." + hid;
			json.put("code", StringUtil.isEmpty(CacheUtil.getAttribute(key)) ? false : CacheUtil.removeAttribute(key));
			return json.toJSONString();
		} else if (StringUtil.isNotEmpty(did)) {
			key = "sys.submit.fuiou.pay.d." + did;
			json.put("code", StringUtil.isEmpty(CacheUtil.getAttribute(key)) ? false : CacheUtil.removeAttribute(key));
			return json.toJSONString();
		}

		return json.toJSONString();
	}

}
